import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },{
    path:'/Home',
    name:'Home',
    component:() => import('../views/Home.vue')
  },{
    path:'/canshu/:id',
    name:'canshu',
    component:() => import('../views/canshu.vue')
  },{
    path:'/Classify',
    name:'Classify',
    component:() => import('../views/Classify.vue')
  },{
    path:'/Shopping',
    name:'Shopping',
    component:() => import('../views/Shopping.vue')
  },{
    path:'/My',
    name:'My',
    component:() => import('../views/My.vue'),
    meta:{requireLogin:true}
  },{
    path:'/Details/:id',
    name:'Details',
    component:() => import('../views/Details.vue'),
    meta:{requireLogin:false}
    // beforeEnter:(to,from,next) =>{
    //   var is = true;
    //   if(!is){
    //     next('/Home');
    //   }else{
    //     next()
    //   }

    // }
  },{
    path:'/Login',
    name:'Login',
    component:() => import('../views/Login.vue'),
  }
  
]

const router = new VueRouter({
  mode:"history",//去掉#
  routes
})

export default router
